package com.phoenix.jsef.demo.controller;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @version V1.0
 * @ClassName: ExceptionProcessor
 * @Description:TODO(全局异常处理器) @ControllerAdvice+@ExceptionHandler 注解处理全局异常
 * @author: 李启联
 * @date: 2018/10/13 21:46
 * @Copyright: Copyright (c), 2018-2018
 * 申明：本内容未经作者本人同意,禁止外泄以及用于其他的商业项目.
 */
@ControllerAdvice
public class ExceptionProcessor {

    @ResponseBody
    @ExceptionHandler(value = java.lang.Exception.class)
    public Map<String,Object> acceptException(Exception ex){
        Map<String,Object> map = new HashMap<>();
        map.put("errorMsg",ex.getMessage());
        return map;
    }

}